package com.mxpio.erp.common.technology.entity;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.mxpioframework.jpa.annotation.DictAble;
import com.mxpioframework.security.annotation.Dict;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@Entity
@Table(name = "v_mb_erp_technology_bom")
@Schema(description="当前bom主子表关联视图")
@NoArgsConstructor
@AllArgsConstructor
public class VBomInfo implements DictAble, Serializable {
	
	private static final long serialVersionUID = 1L;
	
	@Transient
	private Map<String, String> textMap;

	public String putText(String key, String value) {
		if (textMap == null) {
			textMap = new HashMap<>();
		}
		return textMap.put(key, value);
	}
	@Id
	@Column(name = "BOM_ID_", updatable = false)
	@Schema(description = "Bom主键")
	private String bomId;


	@Column(name = "PARENT_CODE_")
	@Schema(description = "父项物料编号")
	private String parentCode;

	@Column(name = "PARENT_NAME_")
	@Schema(description = "父项物料名称")
	private String parentName;

	@Column(name = "PARENT_SPEC_")
	@Schema(description = "父项物料型号")
	private String parentSpec;

	@Column(name = "PARENT_UNIT_")
	@Schema(description = "父项物料单位")
	@Dict(dicCode="ERP_TECH_UNIT_CODE")
	private String parentUnit;

	@Column(name = "PARENT_DRAWING_NO_")
	@Schema(description = "父项图号")
	private String parentDrawingNo;

	@Column(name = "PARENT_GROUP_")
	@Schema(description = "父项物料组")
	@Dict(dicCode="groupCode", dicEntity = ItemGroup.class, dicText = "groupName")
	private String parentGroup;

	@Column(name = "BASIC_CONSUMPTION_")
	@Schema(description = "基础用量")
	private BigDecimal basicConsumption = BigDecimal.ONE;

	@Column(name = "LEVEL_CODE_")
	@Schema(description = "阶层码")
	private String levelCode;

	@Column(name = "BOM_TYPE_")
	@Schema(description = "BOM类型")
	@Dict(dicCode="ERP_TECH_BOM_TYPE")
	private String bomType;

	@Column(name = "USE_TYPE_")
	@Schema(description = "使用状态")
	@Dict(dicCode="ERP_TECH_USE_TYPE")
	private String useType;

	@Column(name = "VERSION_")
	@Schema(description = "BOM版本")
	private String version;

	@Column(name = "PBEGIN_TIME_")
	@Schema(description = "主物料生效日期")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	private Date pbeginTime;

	@Column(name = "PEND_TIME_")
	@Schema(description = "主物料失效日期")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	private Date pendTime;

	@Column(name = "CHANGE_CODE_")
	@Schema(description = "变更单号")
	private String changeCode;

	@Column(name = "CHANGE_MAN_")
	@Schema(description = "变更人")
	private String changeMan;

	@Column(name = "CHANGE_DATE_")
	@Schema(description = "变更日期")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	private Date changeDate;

	@Column(name = "CHANGE_MEMO_")
	@Schema(description = "变更说明")
	private String changeMemo;

	@Column(name = "PRIMARY_BOM_")
	@Schema(description = "是否当前使用pom",hidden=true)
	private String primaryBom;
	
	@Id
	@Column(name = "BOM_LINE_ID_", updatable = false)
	@Schema(description = "BomLine主键")
	private String bomLineId;

	@Column(name = "LINE_NO_", updatable = false)
	@Schema(description = "行号")
	private String lineNo;



	@Column(name = "ITEM_CODE_")
	@Schema(description = "子项物料编号")
	private String itemCode;

	@Column(name = "ITEM_NAME_")
	@Schema(description = "子项物料名称")
	private String itemName ;

	@Column(name = "ITEM_SPEC_")
	@Schema(description = "子项物料规格型号")
	private String itemSpec;

	@Column(name = "ITEM_GROUP_")
	@Schema(description = "子项物料组")
	@Dict(dicCode="groupCode", dicEntity = ItemGroup.class, dicText = "groupName")
	private String itemProp;

	@Column(name = "ITEM_CONSUMPTION_")
	@Schema(description = "子项物料基本用量")
	private BigDecimal itemConsumption;

	@Column(name = "BEGIN_TIME_")
	@Schema(description = "子物料生效日期")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	private Date beginTime;

	@Column(name = "END_TIME_")
	@Schema(description = "子物料失效日期")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	private Date endTime;

	@Column(name = "WASTAGE_")
	@Schema(description = "损耗率")
	private BigDecimal wastage;

	@Column(name = "MAKE_LENGTH_")
	@Schema(description = "下料长度")
	private BigDecimal makeLength;

	@Column(name = "MAKE_AREA_")
	@Schema(description = "下料面积")
	private BigDecimal makeArea;

	@Column(name = "MAKE_NUM_")
	@Schema(description = "可制数量")
	private BigDecimal makeNum;

	@Column(name = "MATERIAL_")
	@Schema(description = "是否材料")
	@Dict(dicCode = "ERP_COMMON_YESNO")
	private String material;

	@Transient
	@Schema(description = "是否有下级物料，0-无 1-有")
	private Boolean hasSub;
	@Transient
	private List<VBomInfo> children;
}
